<template>
  <van-image width="100%" height="100%" fit="fill" :src="imageUrl" />
</template>
<script lang="ts" setup>
import { ref, reactive, onMounted, computed, onBeforeMount } from "vue";
import { mockApi, checkBrowser, detectDevice } from "@/utils/util";
import guideAndroid from "@/assets/channel/guide-android.png";
import guideIos from "@/assets/channel/guide-ios.png";
import { useRoute, useRouter } from "vue-router";
import { showToast } from "vant";
import { DeviceType, BrowserTypeBrief } from "@/const/emun";

const router = useRouter();

const route = useRoute();

const { isDownload } = route.query;

const deviceType = detectDevice();

// console.log("isDownload: ", isDownload);
console.log("deviceType: ", deviceType);
// showToast("1" + deviceType);

// console.log("typeof isDownload: ", typeof isDownload);

const imageUrl = computed(() => {
  return deviceType == DeviceType.IOS ? guideIos : guideAndroid;
});

onBeforeMount(() => {
  // console.log("isGuide", isGuide.value);
  // let browserType = "WeChat Browser";
  const browserType: BrowserTypeBrief = checkBrowser();
  console.log(BrowserTypeBrief.WECHAT != browserType);
  // showToast(String("WeChat Browser" != browserType));
  // showToast(deviceType);
  // showToast(isDownload);
  // showToast("deviceType:" + deviceType);
  if (BrowserTypeBrief.WECHAT != browserType) {
    if (deviceType == DeviceType.ANDROID) {
      // showToast(deviceType);
      // showToast(String(isDownload == "1"));
      // if (isDownload == "1") {
      //   router.push("/guideDownload");
      // } else {
      //   router.push({ path: "/guideAndroid" });
      // }
      router.push({ path: "/guideDownload" });
    } else if (deviceType == DeviceType.IOS) {
      router.push({ path: "/guideDownloadIos" });
      // showToast(deviceType);
      // if (isDownload == "1") {
      //   router.push("/guideDownloadIos");
      // } else {
      //   router.push({ path: "/guideIos" });
      // }
    }
  }
});
</script>

<style lang="scss" scoped>
.guide-android {
}
</style>
